package com.ywjg.serviceimp;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.ywjg.dao.CheckCompanyDao;
import com.ywjg.model.AppUser;
import com.ywjg.model.CheckCompany;
import com.ywjg.service.IAppUserService;
import com.ywjg.service.ICheckCompanyService;
import com.ywjg.utils.Utils;

@Service
public class CheckCompanyService implements ICheckCompanyService  {
	@Resource
	CheckCompanyDao checkCompanyDao;
	@Resource
	AppUserService appUserService;

	/* (non-Javadoc)
	 * @see com.ywjg.serviceimp.ICheckCompanyService#upDateCompanyInf(com.ywjg.model.CheckCompany)
	 */
	public CheckCompany upDateCompanyInf(CheckCompany c) {
		CheckCompany company = checkCompanyDao.findOne(c.getId());
		Utils.copyPropertiesIgnoreNull(c, company);
		return checkCompanyDao.save(company);

	}
	
	/* (non-Javadoc)
	 * @see com.ywjg.serviceimp.ICheckCompanyService#passCheckCompany(com.ywjg.model.CheckCompany)
	 */
	public void passCheckCompany(CheckCompany c) {
		Integer appUserId = c.getAppUserId();
		AppUser appUser = appUserService.findAppUserById(appUserId);
		appUser.setIsCompany(1);
		appUserService.updateAppUser(appUser);

	}
    /* (non-Javadoc)
	 * @see com.ywjg.serviceimp.ICheckCompanyService#addCompanyInf(com.ywjg.model.CheckCompany)
	 */
	public CheckCompany addCompanyInf(CheckCompany c) {
		return checkCompanyDao.save(c);

	}
    /* (non-Javadoc)
	 * @see com.ywjg.serviceimp.ICheckCompanyService#getCheckCompanyInf(java.lang.Integer)
	 */
	public CheckCompany getCheckCompanyInf(Integer user_id) {
		
		return checkCompanyDao.findByappUserId(user_id);
	}
}
